package it.unina.lab.testing;


import it.unina.lab.costants.Constants;
import it.unina.lab.managers.InteractionManager;
import it.unina.lab.modality.RfidModality;
import it.unina.lab.modality.SpeechModality;
import it.unina.lab.parsing.ParserSmuiml;

import org.apache.log4j.Logger;

import com.continuent.tungsten.commons.patterns.fsm.FiniteStateException;
import com.continuent.tungsten.commons.patterns.fsm.StateMachine;


public class MainTest {

	private static Logger logger = Logger.getLogger(MainTest.class);
	private static StateMachine macchina;
	
	public static void main(String[] args) throws FiniteStateException {
		
		
		logger.info("parsing smuiml file and setting object of smuiml file");
		ParserSmuiml parser = new ParserSmuiml(Constants.HEPHAISTK_SMUIML_FILE);
		parser.parse_file();
		
		InteractionManager IM = new InteractionManager(parser);
		SpeechModality speechM = new SpeechModality("speech", IM);
		RfidModality rfidM = new RfidModality("rfid", IM);
		IM.register(rfidM);
		IM.register(speechM);
		IM.checkLink();
		
		
		
		
	/*	
		MyEntityTest myEntity = new MyEntityTest("ciao");
		StateMachineBuilder builder = new StateMachineBuilder(myEntity, parser.getContexts());
		builder.processContexts();
		builder.processTransitions();
	
		try {
			
			macchina = builder.endBuildProcess();
			macchina.applyEvent(new Event("speech_play"));
			System.out.println(macchina.getState().getName());
			macchina.applyEvent(new Event("rfid_stop"));
			System.out.println(macchina.getState().getName());
			macchina.applyEvent(new Event("rfid_play"));
			System.out.println(macchina.getState().getName());
			
		} catch (TransitionNotFoundException e) {
			logger.info("Ricevuta una transazione non trovata. \n Event: " + e.getEvent().getData() + "\n State: " + e.getState().getName() );
			logger.error(e);
			e.printStackTrace();
		}
		*/
		
	}

}
